package kr.co.handysoft.smartPolice.vo;

import java.io.File;

public class PassData {
	
	private String date;
	private String site;
	private String line;
	private String number;
	private String speed = "0";
	private String ftpPath;
	private String pathString;
	private String centerCode;
	
	public PassData() {}
	
	public PassData(File tgrFile, String masterDirectory, String zone) {
		String[] fileNameArray = tgrFile.getName().split("_");
		this.centerCode = zone;
		this.date = fileNameArray[0];
		this.site = fileNameArray[1];
		this.line = fileNameArray[2];
		this.number = fileNameArray[3];

		if (fileNameArray.length > 4){
			this.speed = fileNameArray[4];
		}else{
			this.speed = "0";
		}
		
		pathString = masterDirectory + "/" +
					this.date.substring(0, 4) + "/" +
					this.date.substring(4, 6) + "/" +
					this.date.substring(6, 8) + "/" +
					this.date.substring(8, 10) + "/" +
					this.date.substring(10, 12) + "/" +
					this.date.substring(12, 14);
		
		new File(pathString).mkdirs();
		
		this.ftpPath = pathString +  "/" + tgrFile.getName();
	}

	
	public String getPathString() {
		return pathString;
	}

	public void setPathString(String pathString) {
		this.pathString = pathString;
	}

	public String getFtpPath() {
		return ftpPath;
	}

	public void setFtpPath(String ftpPath) {
		this.ftpPath = ftpPath;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		String[] datePart0 = date.split(" ");
		String[] datePart1 = datePart0[0].split("-");
		String[] datePart2 = datePart0[1].split(":");
		
		this.date = datePart1[0]+datePart1[1]+datePart1[2]+datePart2[0]+datePart2[1]+datePart2[2].substring(0,2);
	}

	public String getSite() {
		return site;
	}

	public void setSite(String site) {
		this.site = site;
	}

	public String getLine() {
		return line;
	}

	public void setLine(String line) {
		this.line = line;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public String getSpeed() {
		return speed;
	}

	public void setSpeed(String speed) {
		this.speed = speed;
	}

	public void setCenterCode(String centerCode) {
		this.centerCode = centerCode;
		
	}

	public String getCenterCode() {
		return this.centerCode;
	}
	
}
